package com.example.studentportrait.controller.admin;

import com.example.studentportrait.domain.ResponseResult;
import com.example.studentportrait.domain.dto.*;
import com.example.studentportrait.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin")
public class AdminUserController {
    @Autowired
    UserService userService;

    /**
     * 后台管理员管理分页查询
     * @param pageNum
     * @param pageSize
     * @param listUserDto
     * @return
     */
    @GetMapping("/adminList")
    public ResponseResult adminList(Integer pageNum, Integer pageSize, ListUserDto listUserDto){
        return userService.adminList(pageNum,  pageSize,  listUserDto);
    }

    /**
     * 新增管理员
     * @param addAdminDto
     * @return
     */
    @PostMapping("/addAdmin")
    public ResponseResult addAdmin(@RequestBody AddAdminDto addAdminDto){
        return userService.addAdmin(addAdminDto);
    }

    /**
     * 编辑管理员
     * @param updateAdminDto
     * @return
     */
    @PutMapping("/updateAdmin")
    public ResponseResult updateAdmin(@RequestBody UpdateAdminDto updateAdminDto){
        return userService.updateAdmin(updateAdminDto);
    }
}
